// gallery.js
import GalleryComponent from './gallery.vue'

let $vm

const Gallery = {
	install(Vue, options) {
		if (!$vm) {
			const GalleryPlugin = Vue.extend(GalleryComponent);

			$vm = new GalleryPlugin({
				el: document.createElement('div')
			});
			document.body.appendChild($vm.$el);
		}

		let gallery = {
			show(html) {
				$vm.show = true;
				$vm.html = html;
			},
			hide() {
				$vm.show = false;
			}
		};

		if (!Vue.$gallery) {
			Vue.$gallery = gallery;
		}

		Vue.mixin({
			created() {
				this.$gallery = Vue.$gallery;
			}
		})
	}

}

export default Gallery

